//
//  mainTabBar.m
//  weiboObjectC
//
//  Created by 隗杰 on 16/2/12.
//  Copyright © 2016年 kkk. All rights reserved.
//

#import "mainTabBar.h"

@interface mainTabBar ()

@end

@implementation mainTabBar

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    CGFloat w = self.frame.size.width / 5;
    CGFloat h = self.frame.size.height;
    CGRect rect = CGRectMake(0, 0, w, h);
    CGFloat index = 0;
    
    for (UIView *sub in self.subviews) {
        
        if([sub isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
        
//            [sub frame] = CGRectOffset(rect, w * index, 0);
            sub.frame = CGRectOffset(rect, w * index, 0);
            
            index += (index == 1 ? 2 : 1);
            
        }
        
    }

    self.butn.frame = CGRectOffset(rect, w * 2, 0);
    
}

- (UIButton *)butn {
    if (_butn == nil) {
        _butn = [[UIButton alloc] init];
        
        [_butn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
        
        [_butn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
        
        [_butn setImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
        
        [_butn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
        
        [self addSubview:_butn];
        
    }
    return _butn;

}

@end
